<?php

class Activity_Controller_Browse_Ajax_Comment_Addfromfeed extends Nuo_Controller
{
	/**
	 * @todo support to select sender in some case
	 */
	function execute($request)
	{
		$dataId = $request -> getParam('data-id');

		$resource = Nuo::getItem($dataId);

		if ($request -> isPost())
		{
			$body = $request -> getParam('body');

			$comment = Nuo::getApi('activity/comment') -> addComment($resource, $poster = Nuo::getUser(), $body = $_POST['add_comment_text']);

			return  array(
				'success' => 1,
				'html_id' => $request -> getParam('html-id'),
				'html' => Nuo::getView()->render('comment/view/partial/comment', array(
					'viewer' => $poster,
					'activity/comment' => $comment,
					'isUser' => 1,
				))
			);
		}
	}

}
